package com.wyzz.hr.bo.impl;

import java.util.List;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.wyzz.hr.base.BaseAction;
import com.wyzz.hr.bo.IEmployeeBo;
import com.wyzz.hr.pojo.Employee;

public class EmpDistinctNo extends BaseAction {

	public EmpDistinctNo() {
	}

	public static String getEmpDistinctNo(String id) {
		String fetch[] = { "empDistinctNo" };
		Employee employee = getEmployeeBo().loadEmp(id, fetch);
		if (employee != null)
			return employee.getEmpDistinctNo();
		else
			return null;
	}

	public static Employee getEmpNo(String empDistinctNo) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(Employee.class);
		detachedCriteria.add(Restrictions.eq("empDistinctNo", empDistinctNo));
		List list = getEmployeeBo().findByCriteria(detachedCriteria);
		if (list == null || list.size() == 0)
			return null;
		else
			return (Employee) list.get(0);
	}

	public static String getEmpName(String id) {
		String fetch[] = { "empName" };
		Employee employee = getEmployeeBo().loadEmp(id, fetch);
		if (employee != null)
			return employee.getEmpName();
		else
			return null;
	}

	public static IEmployeeBo getEmployeeBo() {
		if (empBo == null)
			empBo = (IEmployeeBo) getBean("empBo");
		return empBo;
	}

	private static final long serialVersionUID = 1L;
	static IEmployeeBo empBo = null;

}
